package com.superhelper.printer.server;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.springframework.stereotype.Service;

import io.netty.channel.Channel;

@Service
public class PrinterInfo {
    private Map<Integer, Printer> printerMap = new ConcurrentHashMap<Integer, Printer>();

    // 更新打印机
    public void renew(Integer printerId, Integer printerStatus, Channel channel) {
        printerMap.put(printerId, new Printer(printerId, channel, printerStatus));
    }

    // -1 打印机没注册 0 正常 4 缺纸 128 过热
    public Printer getPrinter(Integer printerId) {
        Printer printer = printerMap.get(printerId);
        if (printer == null) {
            return null;
        }
        return printer;
    }

}
